/*<summary>
Created By : Preeti
Created On : 9/20/2008
Class Name : Employee_Mapper
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/


using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Utils;

namespace RegistrationController
{
    public class EmployeeInfo_Mapper
    {
        public bool Load_Employee_DATA(string ID, EmployeeInfo objEmployee)
        {
            if (!(objEmployee == null))
            {
                ezUtilsAdapter DBL = new ezUtilsAdapter();
                int ResultVal;
                bool bresult;
                string EmployeeId;
                string EmployeeType;
                string FName;
                string LName;
                string MobilePhone;
                string HomePhone;
                string OfficePhone;
                string Email;
                string Address1;
                string Address2;
                string City;
                string State;
                string ZipCode;

                EmployeeId = objEmployee.EmployeeId;
                EmployeeType = objEmployee.EmployeeType;
                FName = objEmployee.FName;
                LName = objEmployee.LName;
                MobilePhone = objEmployee.MobilePhone;
                HomePhone = objEmployee.HomePhone;
                OfficePhone = objEmployee.OfficePhone;
                Email = objEmployee.Email;
                Address1 = objEmployee.Address1;
                Address2 = objEmployee.Address2;
                City = objEmployee.City;
                State = objEmployee.State;
                ZipCode = objEmployee.ZipCode;

                try
                {
                    ResultVal = DBL.RunSPReturnInteger("SP_SetEmployee",
                    new SqlParameter("@vchID", ID),
                   new SqlParameter("@vchEmployeeId", EmployeeId),
                     new SqlParameter("@vchEmployeeType", EmployeeType),
                     new SqlParameter("@vchFName", FName),
                     new SqlParameter("@vchLName", LName),
                     new SqlParameter("@vchMobilePhone", MobilePhone),
                     new SqlParameter("@vchHomePhone", HomePhone),
                     new SqlParameter("@vchOfficePhone", OfficePhone),
                     new SqlParameter("@vchEmail", Email),
                     new SqlParameter("@vchAddress1", Address1),
                     new SqlParameter("@vchAddress2", Address2),
                     new SqlParameter("@vchCity", City),
                     new SqlParameter("@vchState", State),
                     new SqlParameter("@vchZipCode", ZipCode));
                    if (ResultVal == 0) { bresult = true; } else { bresult = false; } return bresult;
                }
                catch (SqlException ex)
                {
                    string errorMessage = string.Format(
                        "An Error Occurred While Loading the Employee Information to the DB. Message: {0}", ex.Message);
                    //throw new MappingException(errorMessage, ex);}
                    return false;
                }
                finally
                {
                    DBL.Dispose();
                }
            }

            else { return false; }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }


    }
}